<template>
	<view class="wrap">
		<view class="wrap-header">
			<view class="wrap-header-item">请输入验证码</view>
		</view>
		<view class="phone">
			验证码已发送至手机号码
			<view class="phonenumber">{{phone}}</view>
			
			
		</view>
		<view>
			<view class="input-wrap" style="font-size: 42rpx;">
				<!-- 页面显示  如果想要加密形式 给此input加上 password="true" 属性-->
				<input class="input1" type="number" 
				 v-for="(item, index) in input_len" 
				 @tap="onInput" 
				 :key="index" disabled 
				 :value="input_val.length >= index + 1 ? input_val[index] : ''" 
				/>
			</view>
			<!-- 实际监听 -->
			 <input class="input2" v-if="isFocus" 
			  @blur="blurInput" 
			  @input="setInput" 
			  v-model="input_val" 
			  :maxlength="input_len"
			  :focus="true" 
			/>
		</view>
		<view class="gettime">
			{{cutdwone}}秒后可重新获取
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				input_len: 4, // 验证码长度
				input_val: '', // 验证码的值
				isFocus: false,
				phone:'',
				cutdwone:"60"
			};
		},
		onLoad(option) {
			this.phone=option.phone
		},
		methods: {

			onInput() {
				this.isFocus = true;
			},
			setInput(e) {
				this.input_val = e.detail.value;
				if (this.input_val.length == 6) {
					uni.navigateTo({
						url: "../index/index"
					})
				}
			},
			blurInput() {
				this.isFocus = false;
			}
		}
	};
</script>
<style lang="scss">
	.wrap {
		padding: 0 30rpx;
	}
	.phone{
		color: #999999;
		font-size: 30upx;
		.phonenumber{
			font-weight:bold;
			color:rgba(34,34,34,1);
			font-size:38upx;
			margin: 35upx 0 100upx 0;
		}
	}
 
	.wrap-header {
		padding: 90rpx 0;

		.wrap-header-item {
			font-size: 42rpx;
			margin-bottom: 17rpx;
		}
	}

	.input-wrap {
		display: flex;
		justify-content: space-between;
		align-items: center;

		.input1 {
			width: 120rpx;
			height:120rpx;
			border: 1px solid #CCCCCC;
			justify-content: center;
			border-radius:8px;
			text-align: center;
			margin-left:40upx;
		}
	}

	.input2 {
		height: 0;
		width: 0;
	}
	.gettime{
		font-size:26upx;
		font-family:PingFang SC;
		font-weight:500;
		color:#999999;
		margin-top: 40upx;
	}
</style>